home *** CD-ROM | disk | FTP | other *** search
/ Delphi Developer's Kit 1996 / Delphi Developer's Kit 1996.iso / power / bmplbo / main.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-12-22  |  3.0 KB  |  101 lines

  1. unit Main;
  2.  
  3. {
  4.   This is a test program for the TBmpListBox and TBmpComboBox
  5.   components. See BMPLBOX.PAS for details and documentation.
  6.  
  7.   You mmust install the components in BMPLBOX.PAS before running
  8.   this sample program.
  9.  
  10.   The "Color" button shows you how the TransparentColor property
  11.   works. When you click on it, the property switches between blue
  12.   and red. This shows you that the selected color becomes transparent
  13.   when the listbox or combobox item is displayed.
  14.  
  15.   The "Margin" button demonstrates that the gap between the text
  16.   and the bitmap can be dynamically adjusted. This margin also
  17.   applies to the left of the bitmap.
  18.  
  19.   Also, observe how the glyph index is passed to AddObject. The HiWord
  20.   of the pseudo TObject reference is used to pass the glyph index and
  21.   you can use the LoWord for your own needs. You can associate any glyph
  22.   from the bitmap strip to any item in the list.
  23.  
  24.   Since you have access to Items.Objects[i], you can change this value
  25.   dynamically.
  26.  
  27.   Have fun!
  28.  
  29.   -Patrick Philippot (MainSoft sarl)
  30. }
  31.  
  32. interface
  33.  
  34. uses
  35.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  36.   Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, Menus, Bmplbox;
  37.  
  38. type
  39.   TMainForm = class(TForm)
  40.     BmpListBox1: TBmpListBox;
  41.     Button1: TButton;
  42.     Button2: TButton;
  43.     BmpComboBox1: TBmpComboBox;
  44.     Button3: TButton;
  45.     procedure FormCreate(Sender: TObject);
  46.     procedure Button1Click(Sender: TObject);
  47.     procedure Button2Click(Sender: TObject);
  48.     procedure Button3Click(Sender: TObject);
  49.   end;
  50.  
  51. var
  52.   MainForm: TMainForm;
  53.  
  54. implementation
  55.  
  56. {$R *.DFM}
  57.  
  58. procedure TMainForm.FormCreate(Sender: TObject);
  59. begin
  60.   BmpListBox1.Items.AddObject('String 1', TObject(Makelong(0, 0)));
  61.   BmpListBox1.Items.AddObject('String 2', TObject(Makelong(0, 1)));
  62.   BmpListBox1.Items.AddObject('String 3', TObject(Makelong(0, 2)));
  63.   BmpListBox1.Items.AddObject('String 4', TObject(Makelong(0, 3)));
  64.   BmpListBox1.Items.AddObject('String 5', TObject(Makelong(0, 4)));
  65.   BmpComboBox1.Items.AddObject('String 1', TObject(Makelong(0, 0)));
  66.   BmpComboBox1.Items.AddObject('String 2', TObject(Makelong(0, 1)));
  67.   BmpComboBox1.Items.AddObject('String 3', TObject(Makelong(0, 2)));
  68.   BmpComboBox1.Items.AddObject('String 4', TObject(Makelong(0, 3)));
  69.   BmpComboBox1.Items.AddObject('String 5', TObject(Makelong(0, 4)));
  70.  
  71. end;
  72.  
  73. procedure TMainForm.Button1Click(Sender: TObject);
  74. begin
  75.   if BmpListBox1.TransparentColor = clRed then begin
  76.     BmpListBox1.TransparentColor := clBlue;
  77.     BmpComboBox1.TransparentColor := clBlue;
  78.   end else begin
  79.     BmpListBox1.TransparentColor := clRed;
  80.     BmpComboBox1.TransparentColor := clRed;
  81.   end;
  82. end;
  83.  
  84. procedure TMainForm.Button2Click(Sender: TObject);
  85. begin
  86.   if BmpListBox1.LeftMargin = 4 then begin
  87.     BmpListBox1.LeftMargin := 8;
  88.     BmpComboBox1.LeftMargin := 8;
  89.   end else begin
  90.     BmpListBox1.LeftMargin := 4;
  91.     BmpComboBox1.LeftMargin := 4;
  92.   end;
  93. end;
  94.  
  95. procedure TMainForm.Button3Click(Sender: TObject);
  96. begin
  97.   Application.Terminate;
  98. end;
  99.  
  100. end.
  101.